package test;

import java.util.Scanner;

/**
 * @author: 弓赛鹏
 * @create: 2022-03-14 16:26
 * @description:
 */
public class 买不到 {

    public static void main(String[] args) {
        /*方法一：
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        sc.close();
        System.out.println(a*b-a-b);*/


        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int s[] = new int[1000000];
        for (int i = 0; i < a * b; i++) {
            for (int j = 0; j < a * b; j++) {
                if (a * i + b * j >= 1000000)//超过数组范围时退出
                {
                    break;
                }
                s[a * i + b * j]++;
            }
        }
        int k = 0;
        for (int i = a * b - 1; i >= 0; i--) {
            if (s[i] == 0) {
                k = i;
                break;
            }
        }
        System.out.println(k);
    }
}
